package com.wantong.jianpu.fragments.main;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;

import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.wantong.jianpu.BR;
import com.wantong.jianpu.R;
import com.wantong.jianpu.activitys.LoginActivity;
import com.wantong.jianpu.app.XApp;
import com.wantong.jianpu.base.BaseXFragment;
import com.wantong.jianpu.beans.TabBean;
import com.wantong.jianpu.databinding.FragmentMessageBinding;
import com.wantong.jianpu.databinding.FragmentMineBinding;
import com.wantong.jianpu.utils.ActivityManager;
import com.wantong.jianpu.utils.XUtils;
import com.wantong.jianpu.viewmodels.MessageViewModel;
import com.wantong.jianpu.viewmodels.MineViewModel;

import java.util.ArrayList;

import me.goldze.mvvmhabit.utils.AppUtil;

/**
 * @author PACY
 * @date 2022/4/1
 * description: 首页
 */
public class MineFragment extends BaseXFragment<FragmentMineBinding, MineViewModel> {
    public static MineFragment newInstance(String title) {

        Bundle args = new Bundle();
        args.putString("title", title);
        MineFragment fragment = new MineFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_mine;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        binding.versionMiv.setContent("V "+AppUtil.getVersionName());
        viewModel.exitLogin.observe(this, aBoolean -> {
            new XPopup.Builder(getContext()).asConfirm("提示", "确定要退出登录吗？", () -> {
                XUtils.exitLogin();
                startActivity(LoginActivity.class);
                ActivityManager.getActivityManager().finishAllActivity();
            }).show();
        });
    }

}
